<!--Or13-->
<!--13、医疗机构药品经费使用情况调查表-->
<!--
-->
<template>
  <div class="query">
    <div class="check">
      <div class="c_right">
        <!--        name设置为target尾缀，target和iframe保持一致-->
        <el-form id="my-profile" name="or13" method="post" target="reportFrameOr13">
          <!--          医院编码-->
          <el-form-item style="display: none" name="hospital_code">
            <div class="clear">
              <div class="fl">
                <span class="c_tip">医院编码</span>
                <el-input v-model="hospital_code" name="hospital_code" clearable class="c_search" type="text" />
              </div>
            </div>
          </el-form-item>
          <!--          标题-->
          <el-form-item style="display: none" name="header">
            <div class="clear">
              <div class="fl">
                <span class="c_tip">标题</span>
                <el-input v-model="header" name="header" clearable class="c_search" type="text" />
              </div>
            </div>
          </el-form-item>
          <!--          制表时间-->
          <el-form-item style="display: none" name="tabTime">
            <div class="clear">
              <div class="fl">
                <span class="c_tip">制表时间</span>
                <el-input v-model="tabTime" name="tabTime" clearable class="c_search" type="text" />
              </div>
            </div>
          </el-form-item>
          <!--          制表人-->
          <el-form-item style="display: none" name="lister">
            <div class="clear">
              <div class="fl">
                <span class="c_tip">制表人</span>
                <el-input v-model="lister" name="lister" clearable class="c_search" type="text" />
              </div>
            </div>
          </el-form-item>
          <!--          医疗机构（医院名称）-->
          <el-form-item style="display: none" name="medical">
            <div class="clear">
              <div class="fl">
                <span class="c_tip">医疗机构</span>
                <el-input v-model="medical" name="medical" clearable class="c_search" type="text" />
              </div>
            </div>
          </el-form-item>
          <!--          医疗机构（医院名称）-->
          <el-form-item style="display: none" name="StatisticsList">
            <div class="clear">
              <div class="fl">
                <span class="c_tip">统计列表名（三级菜单名）</span>
                <el-input v-model="StatisticsList" name="StatisticsList" clearable class="c_search" type="text" />
              </div>
            </div>
          </el-form-item>

          <!--          时间-->
          <el-form-item style="display: none" name="quarterStart">
            <div class="clear">
              <div class="fl">
                <span class="c_tip">开始季度</span>
                <el-input v-model="quarterStart" name="quarterStart" clearable class="c_search" type="text" />
              </div>
            </div>
          </el-form-item>

          <el-form-item style="display: none" name="quarterEnd">
            <div class="clear">
              <div class="fl">
                <span class="c_tip">结束季度</span>
                <el-input v-model="quarterEnd" name="quarterEnd" clearable class="c_search" type="text" />
              </div>
            </div>
          </el-form-item>

          <el-form-item>
            <div class="clear">
              <div class="fl">
                <span class="c_tip">收费时间</span>
                <el-date-picker
                  v-model="data.startYear"
                  type="year"
                  placeholder="年份"
                  value-format="yyyy"
                  format="yyyy"
                  style="width: 100px;"
                />
                <span style="padding: 0 1px">年第</span>
                <el-input-number v-model="data.startNum" style="width: 100px;" controls-position="right" :min="1" :max="4" />
                <span style="padding: 0 5px">季度 至 </span>
                <el-date-picker
                  v-model="data.endYear"
                  type="year"
                  placeholder="年份"
                  value-format="yyyy"
                  format="yyyy"
                  style="width: 100px;"
                />
                <span style="padding: 0 5px">年第</span>
                <el-input-number v-model="data.endNum" style="width: 100px;" controls-position="right" :min="1" :max="4" />
                <span style="padding: 0 1px">季度</span>
              </div>
            </div>
          </el-form-item>

          <!--          按钮-->
          <el-form-item>
            <div class="sbtn_box">
              <!--              <el-button size="small" type="primary" @click="onSubmit(doctorDrugMixture,'按名称+剂型+规格+厂家','1')">按名称+剂型+规格+厂家</el-button>-->
              <el-button size="small" type="primary" @click="onSubmit(yljg_ypjf)">生成报表</el-button>
              <!--              <el-button size="small" type="primary" @click="onSubmit(moreBydoctor,'医生汇总表','3')">医生汇总表</el-button>-->
            </div>
          </el-form-item>
        </el-form>
      </div>
    </div>
    <el-dialog
      :title="dialogTitle"
      :visible.sync="dialogVisible"
      width="95%"
      @close="closeVisible"
    >
      <!--      修改name-->
      <iframe id="reportFrameOr13" name="reportFrameOr13" width="1390" height="980" />
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="closeVisible">确 定</el-button>
      </span>
    </el-dialog>
    <Poptable
      ref="ptable"
      :p-type="pType"
      ctype="zy"
      @handleGetMedgroup="handleGetMedgroup"
      @handleGetDrugType="handleGetDrugType"
      @handleGetDept="handleGetDept"
      @handleGetDrugDnc="handleGetDrugDnc"
      @handleGetDrug="handleGetDrug"
      @handleGetDoctor="handleGetDoctor"
      @handleGetRoute="handleGetRoute"
      @handleGetDisease="handleGetDisease"
    />
  </div>
</template>

<script>
import Poptable from '../../childComps/poptable'
export default {
  name: 'Or13',
  components: {
    Poptable
  },
  data() {
    return {
      dialogTitle: '',
      // queryType: '', // 查询类型 顺序传值123
      hospital_code: '', // 医院编码
      header: '', // 标题
      tabTime: new Date().getFullYear() + '-' + (new Date().getMonth() + 1) + '-' + new Date().getDate(),	// 制表时间
      lister: '制表人', // 	制表人
      medical: 1, // 医疗机构（医院名称）
      StatisticsList: '医疗机构药品经费使用情况调查表', // 统计列表名（三级菜单名）
      yljg_ypjf: 'http://yuwenbincl.xicp.net:19133/webroot/ReportServer?reportlet=/other/yljg_ypjf.cpt',
      data: {
        startYear: '',
        startNum: '1',
        endYear: '',
        endNum: '1'
      },
      dialogVisible: false,
      pType: '11',
      sbtnFlag: false
    }
  },
  computed: {
    quarterStart: function() {
      return this.data.startYear + '-' + this.data.startNum
    },
    quarterEnd: function() {
      return this.data.endYear + '-' + this.data.endNum
    }
  },
  mounted() {
    const userInfo = localStorage.getItem('user')
    this.lister = JSON.parse(userInfo).real_name
    this.hospital_code = JSON.parse(userInfo).his_code
    this.medical = JSON.parse(userInfo).his_name
  },
  activated() {
    const userInfo = localStorage.getItem('user')
    this.lister = JSON.parse(userInfo).real_name
    this.hospital_code = JSON.parse(userInfo).his_code
    this.medical = JSON.parse(userInfo).his_name
  },
  methods: {
    onSubmit(startUrlValue) {
      if (this.data.startYear > this.data.endYear) {
        this.$message({
          message: '注意！您选择的结束年份小于开始年份，请重新选择',
          type: 'warning'
        })
        this.data.endYear = ''
      } else if (this.data.startYear === this.data.endYear && this.data.startNum > this.data.endNum) {
        this.$message({
          message: '注意！您选择的结束季度小于开始季度，请重新选择',
          type: 'warning'
        })
        this.data.endNum = ''
      } else if (typeof this.data.startYear === 'object' || typeof this.data.endYear === 'object' || this.data.startYear === '' || this.data.endYear === '') {
        this.$message({
          message: '注意！请选择年份',
          type: 'warning'
        })
      } else {
        this.header = this.StatisticsList
        this.dialogTitle = this.StatisticsList
        this.dialogVisible = true
        this.$nextTick(function() {
          document.or13.action = startUrlValue // 通过 form 的 name 获取表单，并将报表访问路径赋给表单的 action
          document.or13.submit() // 触发表单提交事件
        })
      }
    },
    closeVisible() {
      this.dialogVisible = false
    },

    // 科室
    handleGetDept(data) {
      var names = []; var codes = []
      for (var i = 0; i < data.length; i++) {
        names.push(data[i].deptname)
        codes.push(data[i].deptcode)
      }
      this.data.deptcode = codes
      this.data.deptname = names
    },
    // 清空科室
    clearhandleGetDept() {
      this.data.deptcode = []
      this.data.deptname = []
    },

    // 医疗组弹窗
    handleGetMedgroup(data) {
      var names = []
      var codes = []
      for (var i = 0; i < data.length; i++) {
        codes.push(data[i].medgroupcode)
        names.push(data[i].medgroupname)
      }
      this.data.medgroupCodes = codes
      this.data.medgroupCodesName = names
    },
    // 清空医疗组
    clearhandleGetMedgroup() {
      this.data.medgroupCodes = []
      this.data.medgroupCodesName = []
    },
    // 医生
    handleGetDoctor(data) {
      var names = []
      var codes = []
      for (var i = 0; i < data.length; i++) {
        names.push(data[i].doctorname)
        codes.push(data[i].doctorcode)
      }
      this.data.doctorCode = codes
      this.data.doctorName = names
    },
    // 清空医生
    clearhandleGetDoctor() {
      this.data.doctorCode = []
      this.data.doctorName = []
    },
    // 自定义药品属性
    handleGetDrugType(data) {
      var names = []
      for (var i = 0; i < data.length; i++) {
        names.push(data[i].typename)
      }
      this.data.typeName = names
    },
    // 清空自定义药品
    clearhandleGetDrugType() {
      this.data.typeName = []
    },

    // 药品类别
    handleGetDrugDnc(data) {
      var names = []
      var codes = []
      for (var i = 0; i < data.length; i++) {
        names.push(data[i].classtitle)
        codes.push(data[i].classid)
      }
      this.data.clasStitle = names
      this.data.clasStitlecode = codes
    },
    // 清空药品类别
    clearhandleGetDrugDnc() {
      this.data.clasStitle = []
      this.data.clasStitlecode = []
    },

    // 药品
    handleGetDrug(data) {
      var names = []
      var codes = []
      for (var i = 0; i < data.length; i++) {
        codes.push(data[i].uniquecode)
        names.push(data[i].drugname)
      }
      this.data.uniqueName = names
      this.data.uniqueCode = codes
    },
    // 清空药品
    clearhandleGetDrug() {
      this.data.doctorCode = []
      this.data.doctorName = []
    },

    // 给药途径
    handleGetRoute(data) {
      var names = []
      var codes = []
      for (var i = 0; i < data.length; i++) {
        codes.push(data[i].routecode)
        names.push(data[i].routename)
      }
      this.data.routename = names
      this.data.routecode = codes
    },
    // 清空药品
    clearhandleGetRoute() {
      this.data.routename = []
      this.data.routecode = []
    },
    // 诊断/ 疾病
    handleGetDisease(data) {
      var names = []
      var codes = []
      for (var i = 0; i < data.length; i++) {
        codes.push(data[i].discode)
        names.push(data[i].disname)
      }
      this.data.discode = codes
      this.data.disname = names
    },
    clearhandleGetDisease() {
      this.data.discode = []
      this.data.disname = []
    },
    selectPop(val) {
      this.$refs.ptable.show()
      this.pType = val
    }
  }
}
</script>

<style scoped lang="scss">
  .query{
    width:100%;
    height:100%;
    background:#e6edf5;
    .check{
      font-size:12px;
      line-height:40px;
      background:#fff;
      text-align:center;
      .c_left{
        width:115px;
        float:left;
        line-height:65px;
      }
      .c_right{
        overflow:hidden;
        color:#636365;
        border-left:1px solid #e6edf5;
        padding:15px 0;
        position:relative;
        .show_btn{
          position:absolute;
          right:20px;
          bottom:15px;
          border:1px solid #e1e1e1;
          background:#f9fafc;
          border-radius:2px;
          text-align:center;
          line-height:32px;
          width:70px;
          height:32px;
          font-size:14px;
          color:#9f9f9f;
          cursor: pointer;
        }
        .fl{
          margin-bottom:10px;
          display: flex;
          align-content: center;
          align-items: center;
        }
        .c_tip{
          display:inline-block;
          width:100px;
          padding-right:10px;
          text-align:right;
        }
        .c_input{
          width:131px;
          height:40px;
          border:1px solid #dcdfe6;
          border-radius:4px;
          padding-left:5px;
        }
        .c_input::-webkit-input-placeholder {
          color: #dcdfe6;
        }
        .c_input::-ms-input-placeholder {
          color: #dcdfe6;
        }
        .c_input::-moz-input-placeholder {
          color: #dcdfe6;
        }
        .c_search{
          width:300px;
        }
        .c_searchbtn{
          display:inline-block;
          width:34px;
          height:25px;
          margin-left:3px;
          background:#28a4f4;
          color:#fff;
          font-size:12px;
          text-align:center;
          line-height:26px;
          border-radius:6px;
          cursor:pointer;
        }
        .c_searchbtn_clear{
          display:inline-block;
          width:34px;
          height:25px;
          margin-left:3px;
          background:#F56C6C;
          color:#fff;
          font-size:12px;
          text-align:center;
          line-height:26px;
          border-radius:6px;
          cursor:pointer;
        }
        .c_checkbox{
          width:400px;
          height:40px;
          margin-left: 5px;
          display: flex;
          justify-content: left;
        }
        .btn_clear{
          padding:0;
          width:150px;
          height:40px;
          line-height:40px;
        }
        .sbtn_box{
          text-align:left;
          padding-left:82px;
        }
        .c_select{
          width:130px;
        }
        @media screen and (min-width:1466px){
          .c_select{
            width:150px;
          }
          .btn_clear{
            padding:0;
            width:70px;
            height:40px;
            line-height:40px;
          }
          .c_input{
            width:150px;
          }
          .c_searchbtn{
            width:42px;
            margin-left:4px;
          }
          .c_tip{
            width:100px;
          }
        }
      }
    }
    .list_tip{
      font-size:14px;
      color:#29a4f2;
      padding: 2px;
    }
    .table_box{
      padding:0 18px;
    }
  }
  /deep/.el-checkbox__label{
    width: 100px;
    font-size: 12px;
  }
  /deep/.el-form-item__content{
    font-size: 12px;
  }
  /deep/.el-form-item{
    margin: 0;
  }
</style>
